"use strict";
// 函数定义
function hello(message) {
    console.log(message);
}
// type用来定义一个类型或者别名
var getUserName = function (firstName, lastName) {
    return firstName + lastName;
};
// 可选参数
function print2(name, age, home) {
}
print2('d'); // 一个也不传
print2('leichao', 24);
print2('leichao', 25, '江西丰城市');
// print('leichao', 25, '江西丰城市','ddd')
// 默认参数
function ajax(url, method) {
    if (method === void 0) { method = 'GET'; }
    console.log(url, method);
}
ajax('/user');
// 剩余参数
function sum() {
    var numbers = [];
    for (var _i = 0; _i < arguments.length; _i++) {
        numbers[_i] = arguments[_i];
    }
    return numbers.reduce(function (pre, cur) {
        return pre + cur;
    }, 0);
}
var res = sum(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
console.log(res);
// 函数重载
var obj = {};
function attr(val) {
    if (typeof val === 'number') {
        obj.age = val;
    }
    else if (typeof val === 'string') {
        obj.name = val;
    }
}
attr(27);
attr('雷超');
// attr(true)
console.log(obj);
